<template>
  <div>
    <el-breadcrumb separator="/" style="margin-top: 20px">
      <el-breadcrumb-item :to="{ path: '/manager/order/tackOut' }"
        >首页</el-breadcrumb-item
      >
      <el-breadcrumb-item :to="{ path: '/manager/feedback/provide' }"
        >即刻反馈</el-breadcrumb-item
      >
    </el-breadcrumb>
    <el-form :model="form" label-width="auto" style="max-width: 600px; margin-top: 50px">
      <el-form-item label="反馈内容">
        <el-input v-model="form.content" type="textarea" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">反馈</el-button>
        <el-button>Cancel</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script lang="ts" setup>
import axios from "axios";
import { ElMessage } from "element-plus";
import { reactive, ref } from "vue";

const token = localStorage.getItem("student_auth_token");
// do not use same name with ref
const form = reactive({
  userId: "",
  content: "",
});
const onSubmit = () => {
  console.log("submit!");
  axios
    .get("/api/feedback/create?content=" + form.content, {
      headers: {
        token: token,
      },
    })
    .then((res) => {
      // console.log("code line-39 \n\r😍 res:\n\r", res);
      if (res.data.success) {
        ElMessage({
          message: "反馈成功",
          type: "success",
        });
      } else {
        ElMessage({
          message: "反馈失败",
          type: "error",
        });
      }
      form.content = "";
    })
    .catch((err) => {
      console.log("code line-43 \n\r😆 err:\n\r", err);
    });
};
</script>
